package org.csu.group4.jpetstore.service;

import org.csu.group4.jpetstore.mybatis.entity.Account;
import org.csu.group4.jpetstore.mybatis.entity.SignOn;
import org.csu.group4.jpetstore.persistence.AccountDAO;
import org.csu.group4.jpetstore.persistence.SignOnDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SignOnService {
    @Autowired
    private SignOnDAO signOnDAO;
    @Autowired
    private AccountDAO accountDAO;

    public SignOn login(SignOn signOn){
        return signOnDAO.findByUsernameAndPassword(signOn);
    }
    public Account getAccount(SignOn signOn){
        return accountDAO.findBySignOn(signOn.getUsername());
    }

    //获取所有用户基本信息的接口
    public List<Account> getAllAccount(){
        return accountDAO.findAll();
    }
    //通过用户名获取Account
    public Account getAccountByUsername(String username){
        return accountDAO.findBySignOn(username);
    }
    public void setAccount(Account account){
        accountDAO.updateAccount(account);
    }
}
